//package nbcp.filter
//
//import org.aspectj.lang.ProceedingJoinPoint
//import org.aspectj.lang.annotation.Around
//import org.aspectj.lang.annotation.Aspect
//import org.aspectj.lang.annotation.Before
//import org.springframework.beans.factory.config.BeanPostProcessor
//import org.springframework.core.annotation.Order
//import org.springframework.stereotype.Component
//import nbcp.base.comm.OpenAction
//
//import nbcp.base.extend.AsString
//import nbcp.base.extend.HasValue
//import nbcp.base.utf8
//import nbcp.base.utils.SpringUtil
//import nbcp.web.*
//
//
//@Aspect
//@Component
//class ActionAopFilterActuator { //: BeanPostProcessor {
////    companion object {
////        private val actionFilters = sortedMapOf<Int, IActionFilter>()
////    }
//
////    override fun postProcessAfterInitialization(bean: Any?, beanName: String?): Any {
////        if (bean is IActionFilter) {
////            //
////            var order = bean::class.java.getAnnotation(Order::class.java)
////
////            actionFilters.put(order?.value ?: 0, bean)
////        }
////
////        return super.postProcessAfterInitialization(bean, beanName)
////    }
//
//    private val packages by lazy {
//        return@lazy SpringUtil.context.environment.getProperty("shop.mvc-parameter-packages").AsString().split(",").filter { it.isNotEmpty() }
//    }
//
//    //"execution(* nbcp.web..*.*(..))"
//    @Around("@annotation(org.springframework.web.bind.annotation.GetMapping) || " +
//            "@annotation(org.springframework.web.bind.annotation.PostMapping) || " +
//            "@annotation(org.springframework.web.bind.annotation.RequestMapping) || " +
//            "@annotation(nbcp.comm.JsonpMapping)")
//    @Throws(Throwable::class)
//    fun doAround(joinPoint: ProceedingJoinPoint): Any? {
//        var className = joinPoint.signature.declaringType.name
//        if (packages.any { return@any className.startsWith(it) }) {
//
//            var clazz = joinPoint.signature.declaringType
//            if (clazz.getAnnotation<OpenAction>(OpenAction::class.java) == null) {
//
//                if (HttpContext.request is MyHttpRequestWrapper) {
//                    var request = HttpContext.request as MyHttpRequestWrapper
//                    if (request.IsProxy == false) {
//                        var response = HttpContext.response as MyHttpResponseWrapper
//
//                        if (request.LoginUser == null) {
//                            response.status = 401;
//                            response.contentType = "text/plain;charset=UTF-8";
//                            response.outputStream.write("您需要登录".toByteArray(utf8));
//                            return null;
//                        }
//                    }
//                }
//            }
//
////            if (actionFilters.any {
////                        return@any it.value.process(joinPoint,request, response) == false
////                    }) {
////                return null;
////            }
//        }
//
//        var args = joinPoint.args
//        if (args.any()) {
//            return joinPoint.proceed(args)
//        } else {
//            return joinPoint.proceed()
//        }
//    }
//}